{extend name="platform/base" /}
{block name="resources"/}
<style>
	
</style>
{/block}
{block name="main"}
<section class="panel panel-default">
	<header class="panel-heading font-bold"> 图片裁剪设置 </header>
	<div class="panel-body">
		<form class="form-horizontal">
            <div class="form-group">
                  <label class="col-lg-2 control-label">默认店铺图片</label>
                  <div class="col-md-2">
					<p class="img-box imglogo-box" id="shop_img_box">
					{if condition="!empty($info.value.default_shop_img)"}
					<img  src="{:__IMG($info['value']['default_shop_img'])}" class="imglogo"/>
					{/if}
					</p>
                         <a href="javascript:void(0);" style="display:block;position:relative;z-index:1;">
                              <span style="width: 97px;height: 34px;position: absolute;left: 0;top: 0;z-index: 2;cursor: pointer;"> 
                              <input hidefocus="true" size="1" class="input-file" name="file_upload" id="shop_img" nc_type="change_store_label" type="file" style="width: 97px;height: 34px;padding: 0;margin: 0;border: none 0;opacity: 0;filter: alpha(opacity = 0);cursor: pointer;" onchange="imgUpload(this);"> 
							  <input type="hidden" id="shop_img_input" value="{$info.value.default_shop_img}" />
							  </span>
						<a class="btn btn-default"><i class="fa fa-cloud-upload text"></i><span class="text">上传图片</span></a>
					    </a>
				</div>
           </div>
           <div class="line line-dashed line-lg pull-in"></div>
              <div class="form-group">
                  <label class="col-lg-2 control-label">默认商品图片</label>
                       <div class="col-md-2">
						<p class="img-box imglogo-box" id="goods_img_box">
						{if condition="!empty($info.value.default_goods_img)"}
						<img src="{:__IMG($info.value.default_goods_img)}" class="imglogo"/>
						{/if}
						</p>
                           <a href="javascript:void(0);" style="display:block;position:relative;z-index:1;">
                            <span style="width: 97px;height: 34px;position: absolute;left: 0;top: 0;z-index: 2;cursor: pointer;"> 
                            <input hidefocus="true" size="1" class="input-file" name="file_upload" id="goods_img" nc_type="change_store_label" type="file" style="width: 97px;height: 34px;padding: 0;margin: 0;border: none 0;opacity: 0;filter: alpha(opacity = 0);cursor: pointer;" onchange="imgUpload(this);"> 
							<input type="hidden" id="goods_img_input" value="{$info.value.default_goods_img}" />
							</span>
							<a class="btn btn-default"><i class="fa fa-cloud-upload text"></i><span class="text">上传图片</span></a>
						</a>
					</div>
              </div>
			<div class="line line-dashed line-lg pull-in"></div>
			
              <div class="form-group">
                  <label class="col-lg-2 control-label">默认会员头像</label>
                       <div class="col-md-2">
						<p class="img-box imglogo-box" id="member_img_box">
						{if condition="!empty($info.value.default_headimg)"}
						<img src="{:__IMG($info.value.default_headimg)}" class="imglogo"/>
						{/if}
						</p>
                           <a href="javascript:void(0);" style="display:block;position:relative;z-index:1;">
                            <span style="width: 97px;height: 34px;position: absolute;left: 0;top: 0;z-index: 2;cursor: pointer;"> 
                            <input hidefocus="true" size="1" class="input-file" name="file_upload" id="member_img" nc_type="change_store_label" type="file" style="width: 97px;height: 34px;padding: 0;margin: 0;border: none 0;opacity: 0;filter: alpha(opacity = 0);cursor: pointer;" onchange="imgUpload(this);"> 
							<input type="hidden" id="member_img_input" value="{$info.value.default_headimg}" />
							</span>
							<a class="btn btn-default"><i class="fa fa-cloud-upload text"></i><span class="text">上传图片</span></a>
						</a>
					</div>
              </div>
              
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<div class="col-sm-4 col-sm-offset-2">
					<a href="javascript:void(0);" onclick="setConfigAjax()" class="btn btn-primary">保存</a>
				</div>
			</div>
		</form>
	</div>
</section>
<script src="ADMIN_JS/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script type="text/javascript">
function imgUpload(event) {
	
	var fileid = $(event).attr("id");
	var data = { 'file_path' : UPLOADCOMMON };
	uploadFile(fileid,data,function(res){
		if(res.code){
			var html = '<img  src="'+ __IMG(res.data) +'" class="imglogo"/>';
			$('#' + fileid + '_box').html(html);
			$('#' + fileid + '_input').val(res.data);
			showTip(res.message,"success");
		}else{
			showTip(res.message,"error");
		}
	});
}

function setConfigAjax(){
	
	var default_shop_img = $("#shop_img_input").val();
	var default_goods_img = $("#goods_img_input").val();
	var default_headimg = $("#member_img_input").val();
	var default_imgWatermark_img = $("#imgWatermark_img_input").val();
	$.ajax({
		type:"post",
		url : "{:__URL('PLATFORM_MAIN/config/pictureDefaultSetting')}",
		data : {
			"default_shop_img" : default_shop_img,
			"default_goods_img" : default_goods_img,
			"default_headimg" : default_headimg
		},
		success : function(data){
			if(data['code'] > 0){
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/config/pictureDefaultSetting')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}
</script>
{/block}
